package cn.com.zsc.util;

import java.sql.Connection;
import java.sql.DriverManager;

import cn.com.zsc.properties.ReadProperties;

/**
 * 数据库连接管理类
 * @author 杨景
 *
 */
public class DBConnect {
	/**
	 * 构造方法 
	 */
	public DBConnect() {
		
	}
	
	/**
	 * 获取数据库连接
	 */
	public static Connection getConnection() {
		ReadProperties rp = new ReadProperties();
		Connection conn = null;

		try {
			Class.forName(rp.getValue("attendance.jdbc.driver"));
			conn = DriverManager.getConnection(rp
					.getValue("attendance.jdbc.url"), rp
					.getValue("attendance.jdbc.username"), rp
					.getValue("attendance.jdbc.password"));
		} catch (Exception ex) {
			System.out.println(">>>数据库连接失败." + ex.getMessage());
			ex.printStackTrace();
		}
			
		return conn;
	}
}
